local nuhao = fk.CreateSkill{
  name = "investiture__nuhao"
}

Fk:loadTranslationTable{
  ["investiture__nuhao"] = "怒号",
  [":investiture__nuhao"] = "出牌阶段，你可以将“饮盏”于本回合交给一名其他角色并视为对一名角色使用【杀】。若二者为相同角色，之不能被响应。",
  ["#investiture__nuhao"] = "怒号：选择要将“饮盏”于本回合交给的角色",

  ["#investiture__nuhao-slash"] = "怒号：视为对一名角色使用【杀】"
}

nuhao:addEffect("active", {
  anim_type = "offensive",
  prompt = "#investiture__nuhao",
  card_num = 0,
  target_num = 1,
  can_use = function (self, player)
    return player:hasSkill("investiture__yinzhan")
  end,
  card_filter = Util.FalseFunc,
  target_filter = function (self, player, to_select, selected)
    return #selected < 1 and not to_select:hasSkill("investiture__yinzhan")
  end,
  on_use = function (self, room, effect)
    local player = effect.from
    local heir = effect.tos[1]
    room:handleAddLoseSkills(player, "-investiture__yinzhan")
    room:handleAddLoseSkills(heir, "investiture__yinzhan")
    room.logic:getCurrentEvent():findParent(GameEvent.Turn):addExitFunc(function ()
      room:handleAddLoseSkills(heir, "-investiture__yinzhan")
      room:handleAddLoseSkills(player, "investiture__yinzhan")
    end)

    if player.dead then return end
    local card = Fk:cloneCard("slash")
    card.skillName = nuhao.name
    local extra_data = { bypass_distances = true, bypass_times = true }
    if player:canUse(card, extra_data) then
      local tos = room:askToChoosePlayers(player, {
        targets = table.filter(room.alive_players, function(p)
          return card.skill:modTargetFilter(player, p, {}, card, extra_data)
        end),
        min_num = 1,
        max_num = 1,
        cancelable = true,
        prompt = "#investiture__nuhao-slash",
        skill_name = nuhao.name,
      })
      if #tos == 1 then
        room:useCard{
          card = card,
          from = player,
          tos = tos,
          extra_data = { yinzhan_disresponsive = (tos[1] == heir) },
        }
      end
    end
  end
})

nuhao:addEffect(fk.TargetSpecified, {
  mute = true,
  can_trigger = function (self, event, target, player, data)
    if player:hasSkill(nuhao.name, true) and player == target and data.firstTarget then
      return data.use.extra_data and data.use.extra_data.yinzhan_disresponsive
    end
  end,
  on_cost = Util.TrueFunc,
  on_use = function (self, event, target, player, data)
    data.disresponsive = true
  end
})

return nuhao